import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { join } from 'path';
//引入
import { NestExpressApplication } from '@nestjs/platform-express';
import { Logger } from 'common/lib/utils/log4js';
import * as Chalk from 'chalk';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  //路径变成：localhost:3000/static/1.jpg
  app.useStaticAssets(join(__dirname, '..', 'public'), {
    prefix: '/static/',
  });

  //模板引起配置
  app.setBaseViewsDir(join(__dirname, '..', 'views')); //模板引擎目录
  app.setViewEngine('ejs'); //模板渲染引擎
  Logger.log(
    Chalk.green(`ejsweb 服务启动成功 `),
    '\n',
    Chalk.yellow(`http://localhost:3000/`),
  );
  await app.listen(3000);
}
bootstrap();
